<?php

use Doraemon\service\position\Api;

/**
 * 好物频道头部信息
 * Class ChannelHeadAction
 */
class HeadInfoAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;
    private $data = [];

    public function main()
    {
        $this->getCategoryList();
        $this->getTopBanner();
        $this->data = $this->data ? $this->data : (object)[];
        $this->setSuccess($this->data);
    }

    private function getCategoryList()
    {
        $category = Api::getTab4Category($this->uid);
        if (!empty($category)) {
            $this->data['category_list']= $category;
        }

    }

    private function getTopBanner()
    {
        $list = Api::tab4TopCarouselBannerList($this->uid);
        if (isset($list['banner_list']) && !empty($list['banner_list'])) {
            $top_banner = array_slice($list['banner_list'], 0, 3);
            $this->data['top_banner']= $top_banner;
        }
    }









}